var t = require("../../../@babel/runtime/helpers/defineProperty"), a = getApp();

Page({
    data: {
        showTip: !1,
        step: 1,
        checkboxGroup: [],
        protocolShow: !1,
        agreement: {},
        CompanyData: {},
        timer: null,
        form: {
            name: "",
            org_code: "",
            legal_name: "",
            legal_idNo: "",
            org_type: "1"
        }
    },
    onLoad: function(t) {},
    onReady: function() {},
    onShow: function() {
        this.checkCompanyData();
    },
    getAgreement: function() {
        var t = this, e = a.getNetAddresss("plugin.yun-sign.frontend.company.get-agreement");
        a._postNetWork({
            url: e,
            success: function(a) {
                var e = a.data;
                1 === e.result ? t.setData({
                    agreement: e.data
                }) : wx.showModal({
                    title: "提示",
                    content: e.msg,
                    showCancel: !1
                });
            },
            fail: function(t) {
                console.log(t, "----失败-----");
            }
        });
    },
    getCompanyData: function() {
        var e = this, o = a.getNetAddresss("plugin.yun-sign.frontend.h5.company.get-company-auth-info");
        a._postNetWork({
            url: o,
            success: function(a) {
                var o, n = a.data;
                (console.log(n.data), 1 === n.result) ? e.setData((o = {
                    CompanyData: n.data
                }, t(o, "form.name", n.data.name), t(o, "form.org_code", n.data.org_code), t(o, "form.legal_name", n.data.legal_name), 
                t(o, "form.legal_idNo", n.data.legal_idNo), o)) : wx.showModal({
                    title: "提示",
                    content: n.msg,
                    showCancel: !1
                });
            },
            fail: function(t) {
                console.log(t, "----失败-----");
            }
        });
    },
    sureIdentify: function() {
        this.data.form.legal_name ? this.data.form.legal_idNo ? this.data.form.org_type ? this.data.form.name ? this.data.form.org_code ? this.authRequest() : a.tips("请填写证件号") : a.tips("请填写组织名称") : a.tips("请选择证件号类型") : a.tips("请填写身份证号") : a.tips("请填写姓名");
    },
    authRequest: function() {
        var t = a.getNetAddresss("plugin.shop-esign.frontend.company.auth-company-v2");
        a._postNetWork({
            url: t,
            data: this.data.form,
            success: function(t) {
                var a = t.data;
                1 === a.result ? wx.redirectTo({
                    url: "/packageH/signIndexPlu/identifyResult/identifyResult?show=company"
                }) : wx.showModal({
                    title: "提示",
                    content: a.msg,
                    showCancel: !1,
                    success: function() {}
                });
            },
            fail: function(t) {
                console.log(t, "----失败-----");
            }
        });
    },
    closeTip: function() {
        this.setData({
            showTip: !1
        });
    },
    checkCompanyData: function() {
        var t = this, e = a.getNetAddresss("plugin.shop-esign.frontend.company.check-company-approve");
        a._getNetWork({
            url: e,
            success: function(a) {
                var e = this, o = a.data;
                1 === o.result ? (t.setData({
                    CompanyData: o.data
                }), t.data.status = o.data.status_code, "0" == t.data.status || "-1" == t.data.status ? t.data.timer && clearInterval(t.data.timer) : "1" == t.data.status ? t.data.timer || (t.data.timer = setInterval(function() {
                    e.checkCompanyData();
                }, 8e3)) : (t.data.timer && clearInterval(t.data.timer), wx.redirectTo({
                    url: "/packageH/signIndexPlu/identifyResult/identifyResult?show=company"
                }))) : (t.data.timer && clearInterval(t.data.timer), wx.showModal({
                    title: "提示",
                    content: o.msg,
                    showCancel: !1
                }));
            },
            fail: function(t) {
                console.log(t, "----失败-----");
            }
        });
    },
    showProtocol: function() {
        this.setData({
            protocolShow: !0
        });
    },
    closePopup: function() {
        this.setData({
            protocolShow: !1
        });
    },
    handlerInput: function(a) {
        var e = a.target.dataset.type;
        this.setData(t({}, "".concat(e), a.detail));
    },
    onHide: function() {
        clearInterval(that.data.timer);
    }
});